<template>
  <!-- 已下架 -->
  <div
    class="btns"
    v-if="!productDetailData.shelveState"
  >
    <button disabled class="btncom">已下架</button>
  </div>
  <!-- 通用购买 -->
  <div
    class="btns"
    v-else-if="data.activityType===0 && data.stockNumber!==0"
  >
    <button class="btncom addCart" @click="clickAddCart">加入购物车</button>
    <button class="btncom buy" @click="buyGood">立即购买</button>
  </div>
  <!-- 团购 -->
  <div
    class="btns"
    v-else-if="data.activityType === 1 && data.stockNumber !== 0"
  >
    <button class="btncom addCart" @click="openGroup(1)" v-if="!ifEnable">我要开团</button>
    <button class="btncom" v-else>未开始</button>
    <button class="btncom buy" @click="buyGood(2)">单独购买</button>
  </div>
  <!-- 秒杀、折扣、场景营销、会员价 -->
  <div
    class="btns"
    v-else-if="data.activityType in [2,3,4,5,8,9] && data.stockNumber!==0"
  >
    <button class="btncom addCart" @click="clickAddCart">加入购物车</button>
    <button class="btncom buy" @click="buyGood">立即购买</button>
  </div>
  <!-- 组合销售 -->
  <div
    class="btns"
    v-else-if="data.activityType === 6"
  >
    <button class="btncom" @click="clickAddCart">组合销售加入购物车</button>
  </div>
  <!-- 会员价 -->
  <div
    class="btns"
    v-else-if="data.activityType === 9"
  >
    <button class="btncom addCart" @click="clickAddCart">加入购物车</button>
    <button class="btncom buy" @click="buyGood">立即购买</button>
  </div>
  <!-- 场景营销 -->
  <div
    class="btns"
    v-else-if="data.activityType === 8"
  >
    <button class="btncom addCart" @click="clickAddCart">加入购物车</button>
    <button class="btncom buy" @click="buyGood">立即购买</button>
  </div>
  <!-- 无库存 -->
  <div
    class="btns"
    v-else-if="data.stockNumber===0 && productDetailData.shelveState"
  >
    <button class="btncom" disabled>已售空</button>
  </div>
  <div class="btns" v-else>
    <button class="btncom" disabled>该规格暂不参与活动</button>
  </div>
</template>

<script setup>
import { defineComponent } from 'vue';

defineComponent({
  name: 'ProductBtns'
})
defineProps({
  data: {
    type: Object,
    default: () => ({})
  },
  shelveState: {
    type: Number
  }
})
defineEmits(['addCart'])
function clickAddCart () {
  emit('addCart')
}
</script>